package com.itheima.Test;

import java.util.Random;

public class test1 {
    public static void main(String[] args) {

        int [] arr = new int[6];
        Random r = new Random();

        System.out.println("数组中的数据为:");
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            arr[i] = r.nextInt(10) + 1;
            if (i == arr.length - 1) {
                System.out.println(arr[i] + " ");
            } else {
                System.out.print(arr[i] + " ");
            }
            sum += arr[i];
        }
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max <= arr[i]) {
                max = arr[i];
            }
        }
        System.out.println("最大值为:" + max);
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (min >= arr[i]) {
                min = arr[i];
            }
        }
        double avg = (double) (sum - max - min) / (arr.length - 2);
        System.out.println("最小值为:" + min);
        System.out.println("平均数为:" + avg);
    }
}
